<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>{$store['title']}</title>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/api.css"/>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/common.css?v=7"/>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/goods-two.css?v=15"/>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/fakeLoader.css">
    <link rel="stylesheet" href="{php echo $this->cur_mobile_path}/css/open-popupx.css?v=3">
    <script src="{php echo $this->cur_mobile_path}/script/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" href="{php echo $this->cur_mobile_path}/mvalidate/validate.css" />
    <script type="text/javascript" src="{php echo $this->cur_mobile_path}/mvalidate/jquery-mvalidate.js" ></script>
    <script type="text/javascript" src="https://www.mh163k.com/template/wap/main/default/js/wap_Dscroll.js?tc=110935" ></script>
    {php $style_list_base = $setting['style_list_base'];}
    <style>
        .rest{
            position: fixed;bottom: 0;left: 0;right: 0;z-index: 3;line-height: 60px;font-size: 20px;background-color: rgba(0, 0, 0, .7);color: #ccc;text-align: center
        }
        .text-icon {
            color: #fff;
        }

        .ziyou-tc {
            background: #FFFFFF;
        }

        .ziyou {
            z-index: 9999;
            position: absolute;
            /*background-image: url("{php echo $this->cur_mobile_path}/image/x.svg?v=1");*/
            /*background-size: 45px 45px;*/
            /*设定TRBL*/
            left: 20px;
            top: 20px;
            width: 45px;
            height: 45px;
            line-height: 30px;
            background: rgba(0, 0, 0, .63);
            border-radius: 1000px;
            padding-top: 8px;
            padding-right: 8px;
            padding-left: 8px;
            color: #fff;
            text-align: center;
            font-size: 14px;
        }
        .foodattributes {
            margin-left: 10px;
            -webkit-box-flex: 0;
            -ms-flex: none;
            flex: none
        }

        .foodattributes span {
            display: inline-block;
            vertical-align: middle;
            padding: 2px 2px;
            line-height: 10px;
            text-align: center;
            border: 1px solid currentColor;
            color: #fff;
            font-size: 12px;
            border-radius: 80px;
        }
        .goodsthumb {
            width: 100%; height: 100%; margin-left: -1.63158px; margin-top: 0px; visibility: visible;
            left: -50%;
            right: -50%;
        }
        .i-add-btn{
            padding:0 7px 2px;  line-height:20px; text-align:center; border-radius:20px;  font-size:20px;
            /*background-color:#fbd163;*/
            background-color:{$style_list_base};
            color: #fff;
        }
        .i-remove-btn{
            border: 1px solid #a7a2a9;padding:0 8px 2px 8px;  line-height:19px; text-align:center;
            border-radius:20px; font-size:19px
        }
        .add-btn,.remove-btn{
            float: right;height: 25px;
        }
        .goods-native-scroll{
            padding: 0 12px;
            float: left;
            overflow: auto;
            height: 260px;
            position: absolute;
            top: 40px;
            left: 0;
            width: 100%;
        }
        .goods-native-scroll ul li{
            padding: 6px 0;
            float: left;
            width: 60px;
            border: 1px solid #f0f0f0;
            font-size: 12px;
            line-height: 20px;
            text-align: center ;
            margin-right: 8px;
            margin-top: 5px;
        }

        .goods-native-scroll ul li.on{
            padding: 6px 0;
            float: left;
            width: 60px;
            /*border: 1px solid #fea000;*/
            border: 1px solid {$style_list_base};
            background-color: {$style_list_base};
            color: #fff;
            font-size: 12px;
            line-height: 20px;
            text-align: center ;
            margin-right: 8px;
            margin-top: 5px;
        }

        .goods-item-num{
            height: 30px;
            line-height: 30px;
            font-size: 16px;
            float: left;
            line-height: 30px;
            padding-top: 10px;
            color:#000
        }
        .goods-item-num span{ height:30px; line-height:30px; padding:0 5px; font-size:14px; color:#000; }

        .goods-list{
            background-color: #fff;
            border-top: 1px solid #cacaca;
            bottom: 0;
            height: 350px;
            position: fixed;
            width: 100%;
            z-index: 99999999;
            display:none;
        }
        .guige {
            border-bottom: 1px solid #f0f0f0;width: 100%;font-size: 14px;line-height: 20px;margin:4px 0 2px;
        }

        .tag.focus::before {
            /*background: #3190e8;*/
            background: {$style_list_base};
            content: "";
            height: 51px;
            left: 0;
            position: absolute;
            top: 0px;
            width: 4px;
        }

        .tag.focus .tag-text{
            font-size: 15px;
            color: {$style_list_base};
        }

        .cart-btn-confirm .inner {
            background-color: {$style_list_base};
            color: #fff;
        }
        .menu-tabs a.selected span {
            border-bottom: 3px solid {$style_list_base};
            color: #2f2f2f;
        }

        .cart-footer button{
            width: 110px;
            height: 50px;
            line-height: 50px;
            font-size: 14px;
            text-align: center;
            float:right;
            background-color: {$style_list_base};
            color: #fff;
            position:absolute;
            right:0;
            top:0;
        }
        .food-price2 {
            color: #bbb;
            font-size: 12px;
        }

        .dish-list-item .counter, .floating-nav-container {
            -webkit-box-direction: normal;
            -webkit-flex-flow: row nowrap;
        }
        .floating-nav-container {
            position: fixed;
            z-index: 9999999;
            bottom: 100px;
            left: 0;
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            overflow: hidden;
            height: 36px;
            -webkit-box-orient: horizontal;
            flex-flow: row nowrap;
            padding: 0 5px 0 0;
            background: rgba(0,0,0,.75);
            -webkit-border-bottom-right-radius: 50px;
            border-bottom-right-radius: 50px;
            -webkit-border-top-right-radius: 50px;
            border-top-right-radius: 50px;
            -webkit-transform: translateX(-156px);
            transform: translateX(-156px);
        }
        .slide-right {
            -webkit-animation: slide-right .3s cubic-bezier(0,.46,.19,.99);
            animation: slide-right .3s cubic-bezier(0,.46,.19,.99);
        }
        .fade-in, .fade-out, .slide-left, .slide-left--modify, .slide-right, .slide-right--modify {
            -webkit-animation-fill-mode: forwards;
            animation-fill-mode: forwards;
            -webkit-transform-origin: left top;
            transform-origin: left top;
        }
        .startgoods{
            color: #F00;font-size: 12px;
            background: url({php echo $this->cur_mobile_path}/image/bc.png) no-repeat left center;
            background-size: 12px 12px;
            -webkit-background-size:12px 12px;padding-left: 14px;
        }
    </style>
    <script>
        $(function () {
            $('.shop-close a').click(function (e) {
                $('.vue-wrapper').animate({"left": "100%"}, 300)
                var timer = setTimeout("close()", 350)
            });
        });
        function close() {
            $('.vue-wrapper').css({"display": "none"})
        }
        function getcoupon()
        {
            var cur_coupon_type = $('#cur_coupon_type').val();
            if (cur_coupon_type == 2) {
                var url = "{$store['btn_coupon_url']}";
                location.href = url;
            }
            if (cur_coupon_type == 1) {
                var url = "{php echo $this->createMobileUrl('GetCounponById', array(), true)}";
                var storeid = "{$storeid}";
                var id = "{$store['btn_coupon_id']}";
                $.ajax({
                    url: url, type: "post", dataType: "json", timeout: "10000",
                    data: {
                        "id": id,
                        "storeid": storeid
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            $.mvalidateTip('领取成功');
                            $('#coupon').hide();
                        } else {
                            $.mvalidateTip(data.msg);
                        }
                    }, error: function () {
                        $.mvalidateTip("数据请求失败");
                    }
                });
            }
        }
    </script>
</head>
<body>
    {php $pagecolor = "background: rgba(0, 0, 0, 0) linear-gradient(to right, ". $setting['style_list_btn1']." 0px, ". $setting['style_list_btn2']." 50%, ". $setting['style_list_btn3']." 100%) repeat scroll 0 0;";}
<div id="mainwrap" class="mainwrap">
    <div id="full" class='weui-popup__container weui-popup__container' style="position:fixed;top:0;left:0;right:0;bottom:0;overflow-y:auto; overflow-y: hidden;z-index: 10999;-webkit-overflow-scrolling:touch;display: none;">
        <div class="ziyou" onclick="history.go(-1)">
            返回
        </div>
        <div class="food-price">
            <div class="weui-popup__modal ziyou-tc" style="transition-timing-function: cubic-bezier(0.1, 0.57, 0.1, 1); transition-duration: 0ms; transform: translate(0px, 0px) translateZ(0px);">
                <div class="">
                    <img id="popup_img" style="width: 100%;" src="" alt="">
                </div>
                <div class="weui-cells_radio">
                    <div class="weui-cells__title" style="color: #000;"><h2 id="popup_title"></h2></div>
                    <div class="weui-cells__title" id="popup_sale"></div>
                    <div class="weui-cells">
                        <div class="weui-cell">
                            <div class="weui-cell__bd">
		                        <span class="weui-cell__bd">
		              	            <span class="food-price">{$setting['currency']}<font id="popup_price"></font></span>
		                        </span>
                            </div>
                            <div class="weui-cell__ft">
                                <div class="j-item-console foodop clearfix" id="popup_btn" dishid="">
                                    {if $goodsdetail['isoptions']==0}
                                    <a href="javascript:;" class="j-add-item add-btn add-food" id="pbtn_add_food" >
                                        <i class="i-add-btn">+</i>
                                    </a>
                                    <span class="j-item-num foodop-num" style="display:none" id="pbtn_num">0</span>
                                    <a class="j-remove-item remove-btn remove-food food_add_{$goods['id']} " href="javascript:;"
                                       id="pbtn_remove_food">
                                        <i class="i-remove-btn">-</i>
                                    </a>
                                    {/if}
                                </div>
                                <div class="j-item-console foodop clearfix" id="popup_btn2" >
                                    {if $goodsdetail['isoptions']==1}
                                    <a class="j-add-item add-btn {if $goodsdetail['isoptions']==0}add-food{/if} " href="javascript:;" {if $goodsdetail['isoptions']==1}onclick="tan({$goodsdetail['id']});"{/if}  id="dishid_{$goodsdetail['id']}" >
                                    <i class="i-add-btn" >
                                        选规格
                                    </i>
                                    </a>
                                    {if !empty($dish_arr[$goodsdetail['id']])}
                                    <span class="j-item-num foodop-num">{$dish_arr[$goodsdetail['id']]}</span>
                                    {else}
                                    <span class="j-item-num foodop-num" style="display:none">0</span>
                                    {/if}
                                    <a class="j-remove-item remove-btn food_add_{$goodsdetail['id']}"
                                       {if empty($dish_arr[$goodsdetail['id']])}style="display:none"{/if} href="javascript:;" onclick="$('#add-cart').click();" >
                                    <i class="i-remove-btn">-</i>
                                    </a>
                                    {/if}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="weui-tab">
                        <div class="weui-navbar">
                            <div class="weui-navbar__item" href="#goodtab1">
                                商品详情
                            </div>
                            <div class="weui-navbar__item" href="#goodtab2">
                                用户评论
                            </div>
                        </div>
                    </div>
                    {php $curpath = '../addons/weisrc_dish/template/mobile/style1/assets/diandanbao/';}
                    <style>
                        @charset "UTF-8";
                        @font-face{
                            font-family:FontAwesome;
                            src:url({$curpath}fontawesome-webfont-b64d4ac71dc58ef78afbc23d0aee020d.eot?v=4.2.0);
                            src:url({$curpath}fontawesome-webfont-b64d4ac71dc58ef78afbc23d0aee020d.eot?#iefix&v=4.2.0) format("embedded-opentype"),
                            url({$curpath}fontawesome-webfont-7b07ce57a267815b7902936332129d46.woff?v=4.2.0) format("woff"),
                            url({$curpath}fontawesome-webfont-9fdf91a58be546aefdb0d503cc72528a.ttf?v=4.2.0) format("truetype"),
                            url({$curpath}fontawesome-webfont-3f8802daf26a29590af69a9be2630c82.svg?v=4.2.0#fontawesomeregular) format("svg");
                        }
                        .red {
                            color: #E4393C !important
                        }
                        .fa {
                            display: inline-block;
                            font: normal normal normal 14px / 1 FontAwesome;
                            font-size: inherit;
                            text-rendering: auto;
                            -webkit-font-smoothing: antialiased;
                            -moz-osx-font-smoothing: grayscale
                        }
                        .fa-star:before {
                            content: "\f005"
                        }
                        .comments-section {
                            border-top: 1px solid #dbdbdb;
                            border-bottom: 1px solid #dbdbdb;
                            padding: 0 10px;
                            background-color: #fff
                        }

                        .comments-section .comment-item {
                            border-bottom: 1px solid #eee;
                            padding: 8px 0
                        }

                        .comments-section .comment-item:last-child {
                            border-bottom: 0
                        }

                        .comments-section .comment-info {
                            font-size: 14px !important
                        }

                        .comments-section .comment-info > div {
                            display: inline-block
                        }

                        .comments-section .comment-reply {
                            margin-left: 10px;
                            border-left: 2px solid #eee;
                            padding-left: 6px
                        }

                        .comments-section .comment-level {
                            margin-left: 10px
                        }

                        .comments-section .time {
                            font-size: 12px
                        }

                        .comments-section .content {
                            color: #333;
                            font-size: 14px
                        }
                    </style>
                    <div class="weui-tab__bd" style="margin-top: 50px;">
                        <div id="goodtab1" class="weui-tab__bd-item infinite">
                            <div class="content-padded"></div>
                        </div>
                        <div id="goodtab2" class="weui-tab__bd-item infinite" style="display: none;">
                            <div class="content-padded">
                                <div class="section comments-section">
                                    <div class="ng-isolate-scope">
                                        {loop $feedbacklist $item}
                                        <div class="comment-item ng-scope">
                                            <div class="comment-info">
                                                <div class="nickname ng-binding">{$item['nickname']}</div>
                                                <div class="comment-level red">
                                                    <i class="fa {if $item['star']>=1}fa-star{else}fa-star-o{/if} ng-scope"></i>
                                                    <i class="fa {if $item['star']>=2}fa-star{else}fa-star-o{/if} ng-scope"></i>
                                                    <i class="fa {if $item['star']>=3}fa-star{else}fa-star-o{/if} ng-scope"></i>
                                                    <i class="fa {if $item['star']>=4}fa-star{else}fa-star-o{/if} ng-scope"></i>
                                                    <i class="fa {if $item['star']>=5}fa-star{else}fa-star-o{/if} ng-scope"></i>
                                                </div>
                                            </div>
                                            <div class="time ng-binding">{php echo date("Y-m-d", $item['dateline'])}</div>
                                            <div class="content ng-binding">{$item['content']}</div>
                                        </div>
                                        {if $item['replycontent']}
                                        <div class="comment-item ng-scope">
                                            <div class="comment-info">
                                                <div class="nickname ng-binding">管理员：</div>
                                            </div>
                                            <div class="content ng-binding">{$item['replycontent']}</div>
                                        </div>
                                        {/if}
                                        {/loop}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="weui-cells__title" id="popup_content">
                    </div>
                    <div class="weui-cells__title" style="height: 65px;"></div>
                </div>
            </div>
        </div>
    </div>
    <script>
        //初始化变量
        max=10,page=1;
        $(function () {
            //切换tab标签
            $(".weui-navbar__item").click(function () {
                var findbox = $($(this).attr("href")).find(".content-padded");
                if (findbox.parent().attr("id") == "goodtab1") {
                    $('#goodtab1').css({"display": "block"});
                    $('#goodtab2').css({"display": "none"});
                } else if (findbox.parent().attr("id") == "goodtab2") {
                    $('#goodtab2').css({"display": "block"});
                    $('#goodtab1').css({"display": "none"});
                }
            })
        })
    </script>

<input type="hidden" id="totalprice" value="{$totalprice}" name="totalprice">
<input type="hidden" id="totalcount" value="{$totalcount}" name="totalcount">
<input type="hidden" id="btnstatus" value="0" name="btnstatus">
<input type="hidden" id="limitprice" value="{$limitprice}" name="limitprice">
{if $isrest == 1}
<div class="rest">
    商家休息中,暂不接单
</div>
{else}
<div id="cart" class="cart" style="left: 0px;z-index: 999999;">
    <div class="cart-tip">
        <div class="j-cart-icon cart-icon {if $totalprice>0}ico-cart-active{/if}">
            <i class="j-ico-cart ico-cart {if $totalprice>0}ico-cart-active{/if}" id="add-cart"></i>

            <div class="j-cart-num cart-num" {if $totalprice>0}style="display: block;"{/if}>{$totalcount}</div>
        </div>
        <div class="j-cart-noempty cart-noempty" {if $totalprice>0}style="display: block;"{/if}>
            <span class="j-cart-price cart-price">共 {$setting['currency']}<font>{$totalprice}</font></span>
            <del class="j-cart-origin cart-origin"></del>
            <br>
        </div>
        <div class="j-cart-empty cart-empty" {if $totalprice==0}style="display: block;
        "{/if}>购物车空空如也～
    </div>
</div>
<div class="cart-btns" style="display:none">
    <a class="cart-btn-unavail" href="javascript:;">
        <span class="combtn inner">休息中</span>
    </a>
</div>
<div class="cart-btns">
    <a class="j-cart-btn-confirm cart-btn-confirm" {if $totalprice>0}style="display:
        block;"{else}style="display:none"{/if}" href="javascript:;">
        <span class="inner" onclick="btnSelectJump();">我选好了</span>
    </a>
    <a class="j-cart-btn-unavail cart-btn-unavail" {if $totalprice==0}style="display:
       block;"{else}style="display:none"{/if}">
    <span class="inner">购物中</span>
    </a>
</div>
</div>
{/if}
</div>
<div class="goods-list" id="goodsoption">
    <div class="popup-cart-actions">
        <button class="button popup-cart-close-btn">关闭</button>
        <span id="option_title">商品规格</span> <span style="color:#fea000;" id="option_price"></span>
    </div>
    <input type="hidden" id="cur_dishid" value="{$goodsdetail['id']}" name="cur_dishid">
    <input type="hidden" id="cur_optionid" value="" name="cur_optionid">
    <div class="goods-native-scroll" id="goods-native-scroll">
        <span class="guige">规格</span>
        <ul id="goodsoptionitem"></ul>
    </div>
    <div class="cart-footer">
        <div class="cart-fl">
            <div class="goods-item-num">
                数量
                <i class="" style="border: 1px solid #a7a2a9;padding:0 7px 2px 7px;  line-height:19px; text-align:center; border-radius:20px; font-size:19px;" onclick="setgoodsoptionnum(2);">-</i>
                <span id="goodsoptionnum">1</span>
                <i class="" style=" background-color:{$style_list_base};padding:0 6px 2px;  line-height:20px; text-align:center; border-radius:20px; font-size:20px;color: #fff;" onclick="setgoodsoptionnum(1);">+</i>
            </div>
        </div>
        <button id="add_option_food">确定</button>
    </div>
</div>
<!--购物车列表-->
<div class="shop-cart"></div>
<div class="cart-list">
    <div class="cart-header">
        <i class="cart-b">
            <div class="cart-n">{$totalcount}</div>
        </i>
    </div>
    <div class="popup-cart-actions">
        <button class="button popup-cart-clear-btn">关闭</button>
        <span>购物车</span>
    </div>
    <div class="native-scroll">
        <ul>
            {loop $cart $item}
            {if $item['total']>0}
            <li dishid="{$item['goodsid']}" optionid="{$item['optionid']}">
                <div class="cart-item-name">{$item['goodstitle']}{if !empty($item['optionname'])}[{$item['optionname']}]{/if}</div>
                <div class="cart-item-price">{$setting['currency']}<font>{$item['price']}</font></div>
                <div class="cart-item-num">
                    <i class="cart-item-add"></i>
                    <span>{$item['total']}</span>
                    <i class="cart-item-jj"></i>
                </div>
            </li>
            {/if}
            {/loop}
        </ul>
    </div>
    <div class="cart-footer">
        <div class="cart-fl">
            共 {$setting['currency']}<strong>{$totalprice}</strong>
        </div>
        <button class="btn1" onclick="btnSelectJump();">我选好了</button>
        <button class="btn2" style="background-color: #a0a0a0;display: none;">我选好了</button>
    </div>
</div>
<div class="top-btn" style="display: none;">
    <a class="react">
        <i class="text-icon">⇧</i>
    </a>
</div>
<script>
    //选择多规格
    function addClass(a, dishid) {
        $(a).addClass("on").siblings().removeClass("on");

        var all_select = 0;
        for (var i = 0; i < $('.que_box').length; i++) {
            if ($('.que_box').find('li.on').length == $('.que_box').length) {
                all_select = 1;
            }
        }
        if (all_select == 1) {
            var specs = "";
            for (var i = 0; i < $('.que_box').length; i++) {
                if (i == ($('.que_box').length - 1)) {
                    specs += $('.que_box').eq(i).find('li.on').attr("specid");
                } else {
                    specs += $('.que_box').eq(i).find('li.on').attr("specid") + "_";
                }
            }

            //获取最后选择好的规格
//            optionid = $(a).attr("specid");
            $('#cur_dishid').val(dishid);
            $('#cur_optionid').val(specs);
            var url = "{php echo $this->createMobileUrl('getselectoption', array(), true)}";
            $.ajax({
                url: url, type: "post", dataType: "json", timeout: "10000",
                data: {
                    "dishid": dishid,
                    "optionid": specs
//                    "specs": specs
                },
                success: function (data) {
                    if (data == 0) {
                        $.mvalidateTip('调试中');
                    } else {
                        $("#option_price").html(data['price']);
                    }
                }, error: function () {
                    $.mvalidateTip("数据请求失败");
                }
            });
        }
    }
</script>
<script>
    function tan(i)
    {
        var url = "{php echo $this->createMobileUrl('getgoodsoption', array(), true)}";
        var params = {
            'id': i
        };
        $.ajax({
            url: url,
            type: "post",
            data: params,
            dataType: 'json',
            success: function (data) {
                "{if $is_not_exists == 0}"
                if (data != 0) {
                    $("#option_price").html(data.price);
                    $("#option_title").html(data.title);
                    $("#goods-native-scroll").html(data.content);
                    $("#goodsoptionnum").html(1)
                    $('#goodsoption').css({"display": "block"});
                    $('#goodsoption').slideDown(400)
                }
                "{/if}"
            }
        });
    }
    function setgoodsoptionnum(type)
    {
        var num= $("#goodsoptionnum").html();
        num =  parseInt(num);
        if (type == 1) {
            num = num+1;
            $("#goodsoptionnum").html(num);
        } else {
            if (num > 1) {
                num = num-1;
                $("#goodsoptionnum").html(num);
            }
        }
    }
</script>

<script>
    $(function () {
        $('.menu-tabs .tab3').click(function () {
            $('.menu-tabs a').removeClass('selected')
            $(this).addClass('selected')
            $('.main-tab2').css({"display": "none"});
            $('.main-tab3').css({"display": "block"});
            $('.asidewrap').css({"display": "none"});
            $('.mainwrap').css({"display": "none"});
            $('.cart').css({"display": "none"});
        });

        $('.qualification').click(function () {
            $('.detail-photo').css({"display": "block"});
            $('.detail-region').css({"display": "none"})
            $('.detail-qualification').css({"display": "none"})
            $('.main-tab3').css({"margin-top": "171px"})
        });
        $('.photo-header').click(function () {
            $('.detail-photo').css({"display": "none"});
            $('.detail-region').css({"display": "block"})
            $('.detail-qualification').css({"display": "block"})
            $('.main-tab3').css({"margin-top": "181px"})
        });


        $('.menu-tabs .tab2').click(function () {
            $('.menu-tabs a').removeClass('selected')
            $(this).addClass('selected')
            $('.main-tab2').css({"display": "block"});
            $('.main-tab3').css({"display": "none"});
            $('.asidewrap').css({"display": "none"});
            $('.mainwrap').css({"display": "none"});
            $('.cart').css({"display": "none"});
        });

        $('.menu-tabs .tab1').click(function () {
            $('.menu-tabs a').removeClass('selected')
            $(this).addClass('selected')
            $('.main-tab2').css({"display": "none"});
            $('.main-tab3').css({"display": "none"});
            $('.asidewrap').css({"display": "block"});
            $('.mainwrap').css({"display": "block"});
            $('.cart').css({"display": "block"});
        });

    });

    function changeBtnSelect() {
        var limitprice = parseFloat($("#limitprice").val());
        var totalprice = parseFloat($("#totalprice").val());
        if (limitprice > 0) {
            if (totalprice >= limitprice) {
                $('.cart-noempty').css({"display": "block"});//选择了
                $('.cart-btn-confirm').css({"display": "block"});//选择了
                $('.cart-btn-unavail').css({"display": "none"});//点菜中
                $('#add-cart').addClass('ico-cart-active');
                $("#btnstatus").val('1');
                $('.btn1').css({"display": "block"});
                $('.btn2').css({"display": "none"});
            } else {
                var showprice = limitprice - totalprice;
                showprice = showprice.toFixed(2);
                $('.cart-btn-unavail span').text('还差' + showprice + '元');

                $('.btn2').css({"display": "block"});
                $('.btn2').text('还差' + showprice + '元');
                $('.btn1').css({"display": "none"});

                $('.cart-btn-confirm').css({"display": "none"});//选择了
                $('.cart-btn-unavail').css({"display": "block"});//点菜中
                $("#btnstatus").val('0');
            }
        } else {
            if (totalprice > 0) {
                $("#btnstatus").val('1');
                $('.cart-noempty').css({"display": "block"});//选择了
                $('#add-cart').addClass('ico-cart-active');
                ;
                $('.cart-btn-confirm').css({"display": "block"});//选择了
                $('.cart-btn-unavail').css({"display": "none"});//点菜中
            } else {
                $("#btnstatus").val('0');
                $('.cart-btn-confirm').css({"display": "none"});//选择了
                $('.cart-btn-unavail').css({"display": "block"});//点菜中
            }
            $('.btn1').css({"display": "block"});
            $('.btn2').css({"display": "none"});
        }
    }
    function btnSelectJump() {
        var url = "{$jump_url}";
        var status = $("#btnstatus").val();
        if (status == 1) {
            location.href = url;
        } else {
            var limitprice = parseFloat($("#limitprice").val());
            var totalprice = parseFloat($("#totalprice").val());
            var showprice = limitprice - totalprice;
            showprice = showprice.toFixed(2);
            if (showprice > 0) {
                $.mvalidateTip('还差' + showprice + '元');
                return false;
            } else {
                location.href = url;
            }
        }
    }
</script>
<script src="{php echo $this->cur_mobile_path}/script/fly.min.js"></script>
<script>
    $(document).scroll(function () {
    });
    $(function () {
        $("#add_option_food").click(function (event) {
            cur_dishid = $('#cur_dishid').val();
            cur_optionid = $('#cur_optionid').val();
            ojb = $('#dishid_' + cur_dishid);

            for (var i = 0; i < $('.que_box').length; i++) {
                if ($('.que_box').eq(i).find('li.on').length < 1) {
                    $.mvalidateTip("请选择" + $('.que_box').eq(i).find('.guige').html());
                    return false;
                }
            }
            //规格商品数量
            goodsoptionnum = parseInt($('#goodsoptionnum').html());

            var fnum = ojb.parent().find('.foodop-num');//商品数量标签
            var jian = ojb.parent().find('.remove-btn');//减少数量标签
            var car = $('#add-cart');//改变购物车背景
            var cartnum = $('.cart-num');//没有商品 空
            var cart_n = $('.cart-n');//没有商品 空

            var carempty = $('.cart-empty');//有商品
            var goodsprice = ojb.parent().next().find('font').text();//商品单价
            var cartnoempty = $('.cart-noempty');	//总价格位置
            var totalprice = $('.cart-noempty').find('font').text();//总价格
            if (totalprice != 0) {
                totalprice = parseFloat(totalprice) + parseFloat(goodsprice);
            } else {
                totalprice = parseFloat(goodsprice);
            }
            totalprice = totalprice.toFixed(2);

            var cartbtnconfirm = $('.cart-btn-confirm'); //结算
            var cartbtnunavail = $('.cart-btn-unavail'); //差10元起送

            var total = $('.cart-num').text();//总数
            total = parseInt(total) + 1;

            var dishid = ojb.parent().attr('dishid');

            totalnum = parseInt(goodsoptionnum);
            var url = "{php echo $this->createMobileUrl('UpdateDishNumOfCategory', array('storeid' => $storeid, 'from_user' => $from_user), true)}";
            var params = {
                'dishid': cur_dishid,
                'optionid':cur_optionid,
                'o2uNum':totalnum,
                'optype':'add'
            };
            $.ajax({
                url: url,
                type: "post",
                data: params,
                dataType: 'json',
                success: function (data) {
                    if (data['message']['code'] != 0) {
                        $.mvalidateTip(data['message']['msg']);
                        return;
                    } else {
                        $('.native-scroll').html(data['message']['cart']);
                        doSelectBtn();
                        totalprice = data['message']['totalprice'];
                        totalcount = data['message']['totalcount'];
                        goodscount = data['message']['goodscount'];

                        $("#totalprice").val(totalprice);
                        changeBtnSelect();

                        fnum.css({"display": "block"});////成功加入购物车动画效果
                        fnum.text(goodscount);//增加数量

                        jian.css({"display": "block"});
                        car.addClass('ico-cart-active');//购物车背景
                        cartnoempty.css({"display": "block"});
                        cartnoempty.find('font').text(totalprice) //总价
                        cartnum.css({"display": "block"});
                        carempty.css({"display": "none"});//隐藏空空
                        $('.cart-footer').find('strong').text(totalprice);
                        cartnum.text(totalcount); //购物车商品总数
                        cart_n.text(totalcount); //购物车商品总数

                        $('#goodsoption').slideUp(400);
                    }
                }
            });
        });

        $('.popup-cart-close-btn').click(function (e) {
            $('#goodsoption').slideUp(400);
        });


        $('.close-popup').click(function (e) {
            $("#full").css({"display": "none"});
            $("#full").removeClass();
            $("#full").addClass("weui-popup__container");
        });

        $('.food-pic-wrap').click(function (e) {


        });

//导航菜单
        $('.tag').click(function (e) {
            var ind = $(this).index()//data-group-id
            var scroll_offset = $('.foodlistwrap h3').eq(ind).offset();
            $('html,body').animate({
                scrollTop: scroll_offset.top - 171  //让mainwrap的scrollTop等于pos的top，就实现了滚动
            }, 500);
        });

        var offset = $("#add-cart").offset();
        var lastClickTime = new Date().getTime();
        var delay = 1000; // 解决延迟 联系点击bug

        $(".add-food").click(function (event) {
            lastClickTime = new Date().getTime();
            var sum = $(this).parent().find('.foodop-num').text();
            if (sum == 0) {
                sum = 1;
            } else {
                sum++
            }
            var fnum = $(this).parent().find('.foodop-num');
            var jian = $(this).parent().find('.remove-btn');
            var car = $('#add-cart');//改变购物车背景
            var cartnum = $('.cart-num');//没有商品 空
            var cart_n = $('.cart-n');//没有商品 空

            var carempty = $('.cart-empty');//有商品
            var goodsprice = $(this).parent().next().find('font').text();//商品单价
            var cartnoempty = $('.cart-noempty');	//总价格位置
            var totalprice = $('.cart-noempty').find('font').text();//总价格
            if (totalprice != 0) {
                totalprice = parseFloat(totalprice) + parseFloat(goodsprice);
            } else {
                totalprice = parseFloat(goodsprice);
            }
            totalprice = totalprice.toFixed(2);

            var dishid = this.parentNode.getAttribute('dishid');
            var o2uNum = parseInt(this.parentNode.children[1].innerHTML, 10);
            o2uNum = parseInt(o2uNum) + 1;
            var url = "{php echo $this->createMobileUrl('UpdateDishNumOfCategory', array('storeid' => $storeid, 'from_user' => $from_user), true)}";
            //商品列表的标签
            var food = $('.food_add_' + dishid);
            var fnum = food.parent().find('.foodop-num');
            var jian = food.parent().find('.remove-btn');
            jian.css({"display": "block"});

            var img = food.parent().parent().parent().find('img').attr('src'); //获取当前点击图片链接
            var flyer = $('<img class="flyer-img" src="' + img + '">'); //抛物体对象

            var params = {
                'dishid': dishid,
                'o2uNum': o2uNum
            };
            $.ajax({
                url: url,
                type: "post",
                data: params,
                dataType: 'json',
                success: function (data) {
                    if (data['message']['code'] != 0) {
                        $.mvalidateTip(data['message']['msg']);
                        return;
                    } else {
                        $('.native-scroll').html(data['message']['cart']);
                        doSelectBtn();
                        totalprice = data['message']['totalprice'];
                        totalcount = data['message']['totalcount'];
                        goodscount = data['message']['goodscount'];

                        $("#totalprice").val(totalprice);
                        changeBtnSelect();
                        flyer.fly({
                            start: {
                                left: event.clientX - 25,//抛物体起点横坐标
                                top: event.clientY - 25 //抛物体起点纵坐标
                            },
                            end: {
                                left: offset.left + 10,//抛物体终点横坐标
                                top: offset.top + 20 //抛物体终点纵坐标
                            },
                            onEnd: function () {
                                this.destory(); //销毁抛物体
                            }
                        });
                        fnum.css({"display": "block"});////成功加入购物车动画效果
                        jian.css({"display": "block"});
                        car.addClass('ico-cart-active');//购物车背景
                        cartnoempty.css({"display": "block"});
                        cartnoempty.find('font').text(totalprice) //总价
                        cartnum.css({"display": "block"});
                        carempty.css({"display": "none"});//隐藏空空
                        $('.cart-footer').find('strong').text(totalprice);
                        fnum.text(goodscount);//增加数量
                        cartnum.text(totalcount); //购物车商品总数
                        cart_n.text(totalcount); //购物车商品总数
                    }
                }
            });
        });

        $(".remove-food").click(function (event) {
//		if (new Date().getTime() - lastClickTime < delay) {
//			return;
//	  	}
            lastClickTime = new Date().getTime();
            var fnum = $(this).parent().find('.foodop-num');
            var sum = $(this).parent().find('.foodop-num').text();//商品数量
            var jian = $(this).parent().find('.remove-btn');
            sum--;
            if (sum < 1) {
                fnum.css({"display": "none"});
                jian.css({"display": "none"});
            }
            fnum.text(sum)
            var cartnum = $('.cart-num').text();//商品总数减1

            var car = $('#add-cart');//改变购物车背景
            cartnum = cartnum - 1;
            if (cartnum < 1) {
                car.removeClass('ico-cart-active');
                $('.cart-num').css({"display": "none"})
            }
            $('.cart-num').text(cartnum);
            $('.cart-n').text(cartnum); //购物车商品总数
            var totalprice = $('.cart-noempty').find('font').text();//总价钱


            var dishid = this.parentNode.getAttribute('dishid');
            var o2uNum = parseInt(this.parentNode.children[1].innerHTML, 10);

            var food = $('.food_add_' + dishid);
            var fnum = food.parent().find('.foodop-num');
            var jian = food.parent().find('.remove-btn');
            fnum.text(sum)

            var url = "{php echo $this->createMobileUrl('UpdateDishNumOfCategory', array('storeid' => $storeid, 'from_user' => $from_user), true)}";
            var params = {
                'dishid': dishid,
                'o2uNum': o2uNum
            };
            $.ajax({
                url: url,
                type: "post",
                data: params,
                dataType: 'json',
                success: function (data) {
                    if (data['message']['code'] != 0) {
                        $.mvalidateTip(data['message']['msg']);
                        return;
                    } else {
                        totalprice = data['message']['totalprice'];
                        totalcount = data['message']['totalcount'];
                        goodscount = data['message']['goodscount'];

                        if (goodscount < 1) {
                            fnum.css({"display": "none"});
                            jian.css({"display": "none"});
                        }

                        if (totalcount < 1) {
                            car.removeClass('ico-cart-active');
                            $('.cart-num').css({"display": "none"})
                        }
                        $('.cart-num').text(totalcount);
                        $('.cart-n').text(totalcount); //购物车商品总数

                        $('.native-scroll').html(data['message']['cart']);
                        doSelectBtn();
                        totalprice = totalprice.toFixed(2);
                        $("#totalprice").val(totalprice);
                        changeBtnSelect();
                        if (totalprice == 0) {
//                            carempty.css({"display": "block"});
//                            cartnoempty.css({"display": "none"});
//                            cartbtnunavail.css({"display": "block"});//起送
//                            cartbtnconfirm.css({"display": "none"});
                        }
                        $('.cart-noempty').find('font').text(totalprice);
                        $('.cart-footer').find('strong').text(totalprice);
                    }
                }
            });
        });

        $('#add-cart').click(function (e) {
            changeBtnSelect();
            var cartnum = $('.cart-num').text();
            if (cartnum > 0) {
                $('.shop-cart').css({"display": "block"});
                $('.cart-list').slideDown(400);
                $('.cart-list').css({"overflow": ""})
            }
        });
        $('.shop-cart').click(function (e) {
            $(this).css({"display": "none"})
            $('.cart-list').slideUp(200)

        });
    });
    function showdetail()
    {
        var dishid = {$id};

        $("#full").addClass("weui-popup__container--visible");
        $('#full').slideToggle(300);

        var url = "{php echo $this->createMobileUrl('getgoodsdetail', array(), true)}";
        var params = {
            'id': dishid,
            'storeid':{$storeid}
        };
        $.ajax({
            url: url,
            type: "post",
            data: params,
            dataType: 'json',
            success: function (data) {
                if (data != 0) {
                    $("#popup_img").attr("src", data['thumb'])
                    $("#popup_title").html(data['title']);
                    $("#popup_price").html(data['dprice'] + '/' + data['unitname']);
                    $("#popup_sale").html("已售 " + data['sales']);
                    $("#goodtab1").find(".content-padded").html(data['content']);
//                        $("#popup_btn").html($(".list" + dishid).html());
                    $("#popup_btn").attr("dishid", dishid);
                    $("#pbtn_remove_food").removeClass();
                    $("#pbtn_remove_food").addClass("j-remove-item remove-btn remove-food food_add_" + dishid);

                    if (data['isoptions'] == 1) {
                        $("#popup_btn2").html($(".list" + dishid).html());
                        $("#popup_btn").css({"display": "none"});
                        $("#popup_btn2").css({"display": "block"});
                    } else {
                        $("#popup_btn").css({"display": "block"});
                        $("#popup_btn2").css({"display": "none"});
                    }
                    if (data['is_sale_end'] == 1) {
                        $("#popup_btn").css({"display": "none"});
                        $("#popup_btn2").css({"display": "none"});
                    }
                    if (data['total'] == 0) { //无商品
                        $("#pbtn_remove_food").css({"display": "none"});
                        $("#pbtn_num").css({"display": "none"});
                    } else {
                        $("#pbtn_remove_food").css({"display": "block"});
                        $("#pbtn_num").css({"display": "block"});
                        $("#pbtn_num").text(data['total']);
                    }
                } else {
                    $("#goodtab1").find(".content-padded").html('');
                }
            }
        });
    }


    function doSelectBtn() {
        var btnAdd = $(".cart-item-add");
        var btnMin = $(".cart-item-jj");
        var btnClean = $(".popup-cart-clear-btn");
        //清空按钮
        btnClean.on('click', function () {
            var url = "{php echo $this->createMobileUrl('clearmenu', array('storeid' => $storeid, 'from_user' => $from_user, 'type' => 'ajax'), true)}";
            $('.remove-btn').css({"display": "none"});
            $('.shop-cart').css({"display": "none"})
            $('.cart-list').slideUp(200)

            var params = {};
//            $.ajax({
//                url: url,
//                type: "post",
//                data: params,
//                dataType: 'json',
//                success: function (data) {
//                    if (data['message']['code'] != 0) {
//                        $.mvalidateTip(data['message']['msg']);
//                        return;
//                    } else {
//                        $("#totalprice").val(0);
//                        changeBtnSelect();
//
//                        $('.native-scroll').html('<ul></ul>');
//                        $('.cart-empty').css({"display": "block"});
//                        $('.cart-btn-unavail').css({"display": "block"});
//                        $('#add-cart').removeClass('ico-cart-active');
//
//                        $('.foodop-num').css({"display": "none"});
//                        $('.foodop-num').text(0);
//
//                        $('.remove-btn').css({"display": "none"});
//                        $('.cart-num').css({"display": "none"});
//                        $('.cart-noempty').css({"display": "none"})
//                        $('.cart-btn-confirm').css({"display": "none"})
//                        $('.cart-noempty').find('font').text(0);
//                        $('.cart-footer').find('strong').text(0);
//                        $('.shop-cart').css({"display": "none"})
//                        $('.cart-list').slideUp(200)
//                        $('.cart-n').text(0);
//                        $('.cart-num').text(0);
//                    }
//                }
//            });
        });
        //增加按钮
        btnAdd.on('click', function () {
            var dishid = this.parentNode.parentNode.getAttribute('dishid'); //商品编号
            var optionid = this.parentNode.parentNode.getAttribute('optionid'); //规格编号

            var goodsnum = $(this).next().text();
            goodsnum = parseInt(goodsnum) + 1;
            $(this).next().text(goodsnum);
            var totalprice = $('.cart-fl strong').text()//总价
            var cartprice = $(this).parent().parent().find('font').text();
            totalprice = parseFloat(totalprice) + parseFloat(cartprice);
            totalprice = totalprice.toFixed(2);
            $('.cart-fl strong').text(totalprice)
            var totalcount = $('.cart-n').text();
            totalcount = parseInt(totalcount) + 1;
            $('.cart-n').text(totalcount);
            $('.cart-num').text(totalcount);//没有商品 空

            //商品列表的标签
            var food = $('.food_add_' + dishid);
            //商品列表现有数量
            var fnum = food.parent().find('.foodop-num');

            var url = "{php echo $this->createMobileUrl('UpdateDishNumOfCategory', array('storeid' => $storeid, 'from_user' => $from_user), true)}";
            var params = {
                'dishid': dishid,
                'optionid':optionid,
                'o2uNum': goodsnum
            };
            $.ajax({
                url: url,
                type: "post",
                data: params,
                dataType: 'json',
                success: function (data) {
                    if (data['message']['code'] != 0) {
                        $.mvalidateTip(data['message']['msg']);
                        return;
                    } else {
                        totalprice = data['message']['totalprice'];
                        totalcount = data['message']['totalcount'];
                        goodscount = data['message']['goodscount'];
                        fnum.text(goodscount);//增加数量

                        $('.native-scroll').html(data['message']['cart']);
                        doSelectBtn();
                        $('.cart-noempty').find('font').text(totalprice);
                        $('.cart-footer').find('strong').text(totalprice);

                        $("#totalprice").val(totalprice);
                        changeBtnSelect();
                    }
                }
            });
        });
        //减少按钮
        btnMin.on('click', function () {
            var dishid = this.parentNode.parentNode.getAttribute('dishid'); //商品编号
            var optionid = this.parentNode.parentNode.getAttribute('optionid'); //规格编号
            var goodsnum = $(this).prev().text();
            goodsnum = parseInt(goodsnum) - 1;
            $(this).prev().text(goodsnum);
            if (goodsnum == 0) {
                $(this).parent().parent().css({"display": "none"})
                $(this).next().text(0);
            }
            var totalprice = $('.cart-fl strong').text()//总价

            var cartprice = $(this).parent().parent().find('font').text();
            totalprice = parseFloat(totalprice) - parseFloat(cartprice);
            totalprice = totalprice.toFixed(2);

            var totalcount = $('.cart-n').text();
            totalcount = parseInt(totalcount) - 1;

            var food = $('.food_add_' + dishid);
            //商品现有数量
            var fnum = food.parent().find('.foodop-num');
            var jian = food.parent().find('.remove-btn');

            $('.cart-n').text(totalcount);
            $('.cart-num').text(totalcount);//没有商品 空

            var url = "{php echo $this->createMobileUrl('UpdateDishNumOfCategory', array('storeid' => $storeid, 'from_user' => $from_user), true)}";
            var params = {
                'dishid': dishid,
                'optionid':optionid,
                'o2uNum': goodsnum
            };
            $.ajax({
                url: url,
                type: "post",
                data: params,
                dataType: 'json',
                success: function (data) {
                    if (data['message']['code'] != 0) {
                        $.mvalidateTip(data['message']['msg']);
                        return;
                    } else {
                        totalprice = data['message']['totalprice'];
                        totalcount = data['message']['totalcount'];
                        goodscount = data['message']['goodscount'];
                        fnum.text(goodscount);//增加数量
                        $('.cart-n').text(totalcount);
                        $('.cart-num').text(totalcount);//没有商品 空

                        if (goodscount == 0) {
                            fnum.css({"display": "none"});
                            jian.css({"display": "none"});
                            $('.shop-cart').css({"display": "none"})
                            $('.cart-list').slideUp(200)
                        }

                        $('.native-scroll').html(data['message']['cart']);
                        doSelectBtn();
                        $('.cart-fl strong').text(totalprice)
                        $('.cart-price font').text(totalprice)

                        if (totalprice == 0) {

                            var carempty = $('.cart-empty');//有商品
                            var cartnoempty = $('.cart-noempty');	//总价格位
                            var cartbtnconfirm = $('.cart-btn-confirm'); //结算
                            var cartbtnunavail = $('.cart-btn-unavail'); //差10元起送

                            $('#add-cart').removeClass('ico-cart-active');
                            $('.cart-num').css({"display": "none"});
                            carempty.css({"display": "block"});
                            cartnoempty.css({"display": "none"});
                            cartbtnunavail.css({"display": "block"});//起送
                            cartbtnconfirm.css({"display": "none"});
                        }

                        $("#totalprice").val(totalprice);
                        changeBtnSelect();
                    }
                }
            });
        });
    }
</script>
<script>
    $('.shopheader-activity-count').on('click', function () {
        $('.top-btn2').toggle(200)
    });
</script>
<script src="{php echo $this->cur_mobile_path}/script/fakeLoader.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        showdetail();
        doSelectBtn();
        changeBtnSelect();
    });
</script>
<script type="text/javascript" src="{RES}/js/fastclick.js"></script>
<script type="text/javascript" src="{RES}/js/jquery.lazyload.min.js"></script>
<script>
    $(function () {
        FastClick.attach(document.body);
        console.log();
        $("img.lazy").lazyload({effect: "fadeIn"});
    });
</script>
{php echo register_jssdk(false);}
<script>
    function jumpsearch() {
        var url = "{php echo $this->createMobileUrl('search', array(), true)}";
        location.href = url;
    }
    function SetCollection() {
        var url = "{php echo $this->createMobileUrl('SetCollection', array('id' => $storeid), true);}";
        $.ajax
        ({
            url: url,
            type: 'POST',
            data: {},
            dataType: 'json',
            error: function () {
                $.mvalidateTip('网络通讯异常，请稍后再试！');
            },
            success: function (result) {
                if (result.status == 1) {
                    $(".shopheader-activity-count").html('<i class="i-favorite"></i>已收藏');
                } else {
                    $(".shopheader-activity-count").html('<i class="i-favorite"></i>收藏');
                }
            }
        });
    }
</script>
<script>
    wx.ready(function () {
        sharedata = {
            title: '{$share_title}',
            desc: '{$share_desc}',
            link: '{$share_url}',
            imgUrl: '{$share_image}',
            success: function () {

            },
            cancel: function () {

            }
        };
        wx.onMenuShareAppMessage(sharedata);
        wx.onMenuShareTimeline(sharedata);
    });
</script>
<link rel="stylesheet" href="{php echo $this->cur_mobile_path}/css/weui.min.css">
{php include $this->template($this->cur_tpl.'/_statistics');}
</body>
</html>
